//MySearchObj.h : Declaration of the CMySearchObj

//***************************************************************************//
//                                                                           //
//  This file was created using the DeskBand ATL Object Wizard 2.0           //
//  By Erik Thompson ?2001                                                  //
//  Email questions and comments to erikt@radbytes.com						 //
//                                                                           //
//***************************************************************************//

#ifndef __MySearchOBJ_H_
#define __MySearchOBJ_H_

#include "resource.h"       // main symbols

//
// These are needed for IDeskBand
//

#include <shlguid.h>
#include <shlobj.h>
#include "BandToolBarCtrl.h"

/////////////////////////////////////////////////////////////////////////////
// CMySearchObj
class ATL_NO_VTABLE CMySearchObj : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CMySearchObj, &CLSID_MySearchObj>,
	public IDeskBand,
	public IObjectWithSite,
	public IPersistStream,
	public IInputObject,
	public IDispatchImpl<IMySearchObj, &IID_IMySearchObj, &LIBID_MySearchLib>
{
public:
	CMySearchObj();

DECLARE_REGISTRY_RESOURCEID(IDR_MySearchOBJ)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_CATEGORY_MAP(CMySearchObj)
//	IMPLEMENTED_CATEGORY(CATID_InfoBand)
//	IMPLEMENTED_CATEGORY(CATID_CommBand)
//	IMPLEMENTED_CATEGORY(CATID_DeskBand)
END_CATEGORY_MAP()

BEGIN_COM_MAP(CMySearchObj)
	COM_INTERFACE_ENTRY(IMySearchObj)
	COM_INTERFACE_ENTRY(IOleWindow)
	COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
	COM_INTERFACE_ENTRY(IObjectWithSite)
	COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
	COM_INTERFACE_ENTRY(IPersist)
	COM_INTERFACE_ENTRY(IPersistStream)
	COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)	
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

// IDeskBand
public:
	STDMETHOD(GetBandInfo)(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi);

// IObjectWithSite
public:
	STDMETHOD(SetSite)(IUnknown* pUnkSite);
	STDMETHOD(GetSite)(REFIID riid, void **ppvSite);
	//Event 
	STDMETHOD(Connect)(void);
	STDMETHOD(Disconnect)(void);

// IDispatch
public:    
	STDMETHOD(Invoke)(DISPID, REFIID, LCID, WORD, DISPPARAMS*, 
		              VARIANT*, EXCEPINFO*, UINT*);


// IOleWindow
public:
	STDMETHOD(GetWindow)(HWND* phwnd);
	STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);

// IDockingWindow
public:
	STDMETHOD(CloseDW)(unsigned long dwReserved);
	STDMETHOD(ResizeBorderDW)(const RECT* prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
	STDMETHOD(ShowDW)(BOOL fShow);

// IPersist
public:
	STDMETHOD(GetClassID)(CLSID *pClassID);

// IPersistStream
public:
	STDMETHOD(IsDirty)(void);
	STDMETHOD(Load)(IStream *pStm);
	STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
	STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);

// IInputObject methods
public:
	STDMETHOD (UIActivateIO) (BOOL, LPMSG);
	STDMETHOD (HasFocusIO) (void);
	STDMETHOD (TranslateAcceleratorIO) (LPMSG);


// IMySearchObj
public:
	void FocusChange(bool bFocus);
    CBandToolBarCtrl* GetToolBarCtrl() {return &m_wndToolBar;}

	STDMETHOD(OnDocumentComplete)(BOOL bForceWindow=false);
	STDMETHOD(OnQuit)(void);
	STDMETHOD(RetrieveBrowserWindow)(void);
	STDMETHOD(GetDocumentContent)(void);
	

protected:
	BOOL RegisterAndCreateWindow();
	

protected:
	DWORD m_dwBandID;
	DWORD m_dwViewMode;
	BOOL m_bShow;
	BOOL m_bEnterHelpMode;
	HWND m_hWndParentRebar;
	HWND m_hWnd;
    LPCSTR m_pszVerb;
    LPCTSTR m_pwszVerb;

	IInputObjectSite* m_pSite;
    IWebBrowser2* m_pWebBrowser;

    CBandToolBarReflectorCtrl m_wndInvisibleChildWnd; // Used for Reflecting Messages
    CBandToolBarCtrl m_wndToolBar;

	CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> m_spCPC;
	CComPtr<IHTMLElement> m_pBody;
	DWORD m_dwCookie;
	BOOL m_bDocumentCompleted ;
	HWND m_hwndBrowser;
	RECT m_rcIE, m_rcHTML;
	_bstr_t m_bstrUrl;
private:
	static BOOL CALLBACK WndEnumProc(HWND, LPARAM); 
	static LRESULT CALLBACK IEKeyboardProc(int, WPARAM, LPARAM);
public:
	BOOL ActiveComboBox()
	{
		m_wndToolBar.m_ctlBandComboBox.SetFocus();
		return TRUE;
	}
};

#endif //__MySearchOBJ_H_